# ~*~ coding: utf-8 ~*~
import time

from apps.common.dbbase import BaseModel
from apps.common.utils import generate_uuid
from apps.extensions import db
from sqlalchemy.dialects.mysql import TINYINT

__all__ = ['Environment']


class Environment(BaseModel):
    __tablename__ = 'codes_environment'

    STATUS_ENABLE = 1
    STATUS_DISABLE = 0

    id = db.Column(db.CHAR(36), default=generate_uuid, primary_key=True)
    name = db.Column(db.VARCHAR(255), unique=True)
    status = db.Column(TINYINT)

    create_by = db.Column(db.VARCHAR(255), nullable=True)
    create_time = db.Column(db.INT, default=time.time)
    update_time = db.Column(db.INT, default=time.time, onupdate=time.time)

    def __str__(self):
        return '<Environment: {}>'.format(self.name)
